Loading libraries
# Main
#library(r5r)
#library(rJava)
#
library(sf)
library(tidyverse)
# Visualization
library(leaflet)
library(tmap)
library(mapview); mapviewOptions(platform = 'leafgl')
Loading Shape Files and Score Data into R
# takes a long time so keep it in a separate cell
# geo data
canada_dbs <- st_read("census_2016_digital_DBS_gml_cartographic/ldb_000b16g_e.gml")
## Reading layer `ldb_000b16g_e' from data source `C:\Users\Luka\Documents\GitHub\Capstone-Project\code\Visualizations\census_2016_digital_DBS_gml_cartographic\ldb_000b16g_e.gml' using driver `GML'
## Simple feature collection with 489676 features and 28 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: 3689439 ymin: 659338.9 xmax: 9015737 ymax: 5242179
## Projected CRS: NAD83 / Statistics Canada Lambert
# keep necessary columns and rows
van_dbs <- data.frame(canada_dbs[which(canada_dbs$CMANAME == "Vancouver"), ])
clean_van_dbs <- van_dbs[, c(1, 2, 29)]
# score data
nearest_gallery_scores <- read.csv("../../data/score_sets/nearest1_gallery_scores.csv")
nearest_gallery_scores$fromId <- as.character(nearest_gallery_scores$fromId)
# join
van_dbs_scores <- left_join(clean_van_dbs, nearest_gallery_scores, by = c('DBUID' = 'fromId'))
head(van_dbs_scores)
# convert back to sf object
van_dbs_scores_sf <- st_as_sf(van_dbs_scores)
# plot blocks if curious but below are the cooler visualizations
#plot(van_dbs$geometry)
Visualizing in tmap
tm_shape(van_dbs_scores_sf) +
tm_polygons("score",
style="quantile",
title="Vancouver Gallery Transit Accessibility")

tmap_mode("view")
## tmap mode set to interactive viewing
tmap_last()